import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () =>
      import(/* webpackChunkName: "about" */ '../views/login/index.vue')
  },
  {
    path: '/',
    name: 'layout',
    component: () => import(/* webpackChunkName: "about" */ '../views/layout'),
    redirect: '/home', // 重新定向到home
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('../views/home')
      },
      {
        path: '/search',
        name: 'search',
        component: () => import('../views/search')
      },
      {
        path: '/message',
        name: 'message',
        component: () => import('../views/message')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('../views/my')
      },
      {
        path: '/search/giftarticle/giftid=:giftId',
        name: 'giftarticle',
        component: () => import('../views/search/components/navbar'),
        props: true
      },
      {
        path: '/search/giftdetail',
        name: 'giftdetail',
        component: () => import('../views/search/components/giftdetail'),
        props: true
      }
    ]
  },
  {
    path: '/myprofiledetail',
    name: '/myprofiledetail',
    component: () =>
      import(/* webpackChunkName: "about" */ '@/components/myprofiledetail.vue')
  }
]

const router = new VueRouter({
  routes
})

export default router
